package ua.in.iticket.addressbook.person;

import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * Created by ivanov-av
 * 05.02.14 15:30.
 */
public class Address {
    protected String country; // страна
    protected String city; // город
    protected String address; // собственно адрес

    public Address(String country, String city, String address) {
        this.country = country;
        this.city = city;
        this.address = address;
    }

    public Address() {

    }

    public String getCountry() {
        return country;
    }

    public String getCity() {
        return city;
    }

    public String getAddress() {
        return address;
    }

    @Override
    public boolean equals(Object obj) {

        if (this == obj) return true;

        if (!(obj instanceof Address)) return false;
        Address that = (Address) obj;

        if (country != null ? !country.equals(that.country) : that.country != null) return false;
        if (city != null ? !city.equals(that.city) : that.city != null) return false;
        if (address != null ? !address.equals(that.address) : that.address != null) return false;
        return true;
    }

    @Override
    public int hashCode() {
        return this.country.hashCode() + this.country.hashCode() + this.address.hashCode();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .appendSuper(super.toString())
                .append("Country", country)
                .append("City", city)
                .append("Address", address)
                .toString();
    }

    public String getFullAdress() {
        return this.country + ", " + this.city + ", " + this.address;
    }
}
